package com.zrc.module_find.activity

import android.util.Log
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.ToastUtils
import com.zrc.superframe_base.ARouterHub
import com.zrc.superframe_base.mvx.mvvm.BaseMvvmActivity
import com.zrc.module_find.R
import com.zrc.module_find.databinding.ActivityStatepagedemoBinding
import com.zrc.module_find.BR
import com.zrc.module_find.viewmodel.FindVM
import com.zrc.superframe_ui.stateview.MultiStateContainer
import com.zrc.superframe_ui.stateview.bindMultiState
import com.zrc.superframe_ui.stateview.state.EmptyState
import com.zrc.superframe_ui.stateview.state.ErrorState
import com.zrc.superframe_ui.stateview.state.LoadingState
import kotlinx.android.synthetic.main.toolbar.*

/**
 * @Author: superman
 * @CreateTime: 6/27/21
 * @Describe:
 */
@Route(path = ARouterHub.ACTIVITY_STATEPAGEDEMO, name = "状态页demo")
class StatePageDemoActivity : BaseMvvmActivity<ActivityStatepagedemoBinding, FindVM>() {

    @Autowired(name = "sm")
    @JvmField
    var sm:Boolean=false

    lateinit var multiStateContainer1: MultiStateContainer

    override fun getVariableId() = BR.viewModel

    override fun getLayoutId() = R.layout.activity_statepagedemo

    override fun getViewModel() = FindVM(this)

    override fun initView() {
        super.initView()
        Log.e("zrc","***********${sm}")
        multiStateContainer1=mBinding.llShow1.bindMultiState()
        toolbar_left.setOnClickListener { finish() }
        toolbar_center.text="状态页在各种环境的使用"

        mBinding.tvLoad.setOnClickListener {
            //multiStateContainer1.show<MyLoadState> ()//默认设置
            multiStateContainer1.show<LoadingState> {
                //这儿可以自定义设置
                it.setLoadingMsg("loading...")
            }
        }
        mBinding.tvLoad.performClick()//加载的时候模拟点击一下

        mBinding.tvEmpty.setOnClickListener {
            //multiStateContainer1.show<MyEmptyState> ()//默认设置
            multiStateContainer1.show<EmptyState> {
                //这儿可以自定义设置
                it.setEmptyIcon(R.drawable.vector_empty)
                it.setEmptyMsg("我是空数据的提示")
            }
        }

        mBinding.tvError.setOnClickListener {
            //multiStateContainer1.show<MyErrorState> ()//默认设置
            multiStateContainer1.show<ErrorState> {
                //这儿可以自定义设置
                it.setErrorIcon(R.drawable.vector_error)
                it.setErrorMsg("我是错误的提示")
                //添加点击事件
                it.retry {
                    ToastUtils.showShort("你点我干嘛，我是有脾气的哈")
                }
            }
        }
    }
}